package com.wxy.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

import com.wxy.domain.history;
import com.wxy.domain.transform;
import com.wxy.domain.user;
import com.wxy.mapper.bankMapper;

@Component("service")
public class serivceImpl implements service{
	@Autowired
	private bankMapper bankMapper;
	@Override
	public List<user> findALLUsers() {
		// TODO 自动生成的方法存根
		return this.bankMapper.findAllUsers();
	}
	@Override
	public int findMaxId() {
		// TODO 自动生成的方法存根
		return bankMapper.findMaxId();
	}
	public void insertUser(user user) {
		// TODO 自动生成的方法存根
	  this.bankMapper.insertUser(user);
	}
	@Override
	public List<history> findAllHistorys() {
		// TODO 自动生成的方法存根
		return this.bankMapper.findAllHistorys();
	}
	@Override
	public int findMoneyByUserName(String username) {
		// TODO 自动生成的方法存根
		return this.bankMapper.findMoneyByUserName(username);
	}
	@Override
	public List<history> findHistoryByCardId(String card_id) {
		// TODO 自动生成的方法存根
		return this.bankMapper.findHistoryByCardId(card_id);
	}
	@Override
	public user findUserByUsername(String username) {
		// TODO 自动生成的方法存根
		return this.bankMapper.findUserByUsername(username);
	}
	@Override
	@Transactional
	public boolean transfer(transform t1, transform t2, history h1, history h2) {
		// TODO 自动生成的方法存根
		this.bankMapper.outMoney(t1);
		this.bankMapper.historyMessage(h1);
		this.bankMapper.inMoney(t2);
		this.bankMapper.historyMessage(h2);
		return true;
	}
	@Transactional
	@Override
	public boolean inMoney(transform transform, history history) {
		// TODO 自动生成的方法存根
		this.bankMapper.inMoney(transform);
		this.bankMapper.historyMessage(history);
		return true;
	}
	@Transactional
	@Override
	public boolean outMoney(transform transform, history history) {
		// TODO 自动生成的方法存根
		this.bankMapper.outMoney(transform);
		this.bankMapper.historyMessage(history);
		return true;
	}
	
}
